﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public partial class Admin_Admin_Group : Admin, IRequiresSessionState
{
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(28))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "UserGroup");
            base.WriteRightErrMsg();
        }
        if (!base.IsPostBack)
        {
            this.BindList();
        }
    }
    protected void BindList()
    {
        GroupBll groupBll = new GroupBll(this.conn);
        this.GridView1.DataSource = groupBll.GetGroups();
        this.GridView1.DataBind();
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "com_del")
        {
            int groupID = Convert.ToInt32(e.CommandArgument);
            GroupBll groupBll = new GroupBll(this.conn);
            int num = groupBll.CountGroup();
            if (num == 1)
            {
                this.WriteErrMsg("", Language.GetAdminMsg("UserGroup/GrouNumErr"), "");
            }
            int num2 = groupBll.CountMemberNumByGroupID(groupID);
            if (num2 > 0)
            {
                this.WriteErrMsg("", Language.GetAdminMsg("UserGroup/UserNumErr", num2.ToString()), "");
            }
            groupBll.DeleteGroup(groupID);
        }
        this.BindList();
    }
}
